// FrogEncryptDialog.cpp : Implementation of CFrogEncryptDialog

#include "stdafx.h"
#include "FrogEncryptDialog.h"
#include "FrogMessageBox.h"

// CFrogEncryptDialog

CFrogEncryptDialog::CFrogEncryptDialog(HICON hIcon):
CFrogProgressReportDialog(hIcon),
m_StrPassword(L""),
m_StrPasswordAgain(L""),
m_DeleteFile(true)
{
}

LRESULT CFrogEncryptDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CFrogBaseDialog::OnInitDialog(uMsg, wParam, lParam, bHandled);
	DoDataExchange(FALSE);

	::SetFocus(GetDlgItem(IDC_EDIT_PASSWORD));

	return 0;
}

LRESULT CFrogEncryptDialog::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	bHandled = TRUE;
	// TODO: Add your control notification handler code here
	DoDataExchange(TRUE);

	m_Password = m_StrPassword;

	if (m_StrPassword != m_StrPasswordAgain)
	{
		FrogMessageBox(m_hWnd, L"Please Retype The Exact Password", L"Password Validation", 0);
		return TRUE;
	}
	else if (m_StrPassword == L"")
	{
		FrogMessageBox(m_hWnd, L"Cannot Enter Empty Password", L"Password Validation", 0);
		return TRUE;
	}

	RunAsyncCommandWithProgressBar(false);

	EndDialog(wID);
	return 0;
}

void CFrogEncryptDialog::ExecuteCommand()
{
	m_FilesRefactor.Encrypt(m_LastResult, m_FilesList, m_Password, m_DeleteFile);
}